Repository navigation
Add ExpireSnapshots.retain_last - #4437
Open
rambleraptor wants to merge 2 commits into
Open
rambleraptor wants to merge 2 commits into
rambleraptor wants to merge 2 commits into
Conversation
Port Java's ExpireSnapshots.retainLast: snapshots that older_than would expire are kept if they are among the N most recent ancestors of a branch. Snapshots expired by ID are unaffected.
rambleraptor
force-pushed
the
expire-snapshots-retain-last
branch
from
November 19, 2026 23:25
142a52d to
0b81a7f
Compare
ebyhr
reviewed
Nov 20, 2026
Fokko
reviewed
Nov 21, 2026
Fokko
left a comment
Contributor
There was a problem hiding this comment.
Thanks @rambleraptor! Nice addition, the chaining example in the docs reads well.
Verified locally: all 17 tests in tests/table/test_expire_snapshots.py pass, CI is green.
One small thing I checked and is fine: by_id snapshots still expire even with retain_last, since they are added directly to _snapshot_ids_to_expire. Also like that the ordering of older_than/retain_last does not matter since the union happens in _commit.
LGTM!
Unlike Java, retain_last alone does not apply history.expire.max-snapshot-age-ms, so it expires nothing. Note this and pin the behavior with a test.
Collaborator
Author
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rationale for this change
This helper method lets you retain the N most recent ancestors of a branch. I've included some doc examples of how you can use this for chaining multiple commands together.
Are these changes tested?
Unit tests included
Are there any user-facing changes?
retain_lastmethod to ExpireSnapshots.